
require("States");

BattleManager = {
	processCombatWithCommonGun = function(attacker, attacked)	
		local worldDt = attacked.world.dt;
			
		if attacked.state == States.ATTACK and attacked.enemy == attacker then 
			local randomProblems = worldDt * math.random();
			if math.random(1,100) > 50 then
				attacked.attributes.hp = attacked.attributes.hp - 
										(attacker.attributes.damage * attacker.attributes.rateOfFire) * 
										randomProblems;						
			else
				attacker.attributes.hp = attacker.attributes.hp - 
										(attacked.attributes.damage * attacked.attributes.rateOfFire) * 
										randomProblems;						
				
			end
		else
			
			attacked.attributes.hp = attacked.attributes.hp - 
									(attacker.attributes.damage * attacker.attributes.rateOfFire) * 
									worldDt;
		end
	end,
	
	
	processCombatWithBullet = function(bullet, attacked)
		if attacked.state ~= States.DEAD then
			attacked.attributes.hp = attacked.attributes.hp - bullet.attributes.damage;
		end
	end
}